package org.xiaom.butler.activity;

import java.util.List;

import org.xiaom.butler.R;
import org.xiaom.butler.bean.Content;
import org.xiaom.butler.bean.Department;
import org.xiaom.butler.dbService.ContentService;

import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;
public class CardDetailActivity extends Activity {
	TextView chName;
	TextView engName;
	TextView address;
	Department d;
	List<Content> contents;
	ContentService cs;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.card_detail);
		d=(Department) getIntent().getSerializableExtra("department");
		cs=new ContentService(this);
		contents=cs.getByDepartment(d.getId().toString());
		initView();
	}
	private void initView() {
		String address="";
		if(contents.size()>0){
			address=contents.get(0).getChContent();
		} 
		Bundle b=getIntent().getExtras();
		Department d;
		chName=(TextView) findViewById(R.id.txt_department_name_ch);
		engName=(TextView) findViewById(R.id.txt_department_name_eng);
		this.address=(TextView) findViewById(R.id.txt_address);
		this.address.setText(address);
		chName.setText(b.getString("address"));
		d=(Department) b.getSerializable("department");
		chName.setText(d.getChName());
		engName.setText(d.getEngName());
	} 
}
